#ifndef APPLICATION_APP_H_H_H_
#define APPLICATION_APP_H_H_H_
#include <boost/signal.hpp>

#include <string>
#include <map>
#define PATHSEP '\\'


#include "Parameter.h"
#include "Observer.h"

class Document_App;

namespace Base 
{
	class ConsoleObserverStd; 
	class ConsoleObserverFile;
}

namespace App
{
	class DocumentObject;
}
class Application_App
{
public:
	Application_App(void);
	~Application_App(void);

public:
	// --document [4/19/2013 Administrator]

	boost::signal<void (const Document_App&)> signalNewDocument;

	boost::signal<void(const App::DocumentObject&)> signalNewObject;

	boost::signal<void (const Document_App&)> signalSaveDocument;

	void slotNewObject(const App::DocumentObject&);

	static void init();
	static void initType();
	static void destruct(void);

	friend Application_App&GetApplication(void);
	static std::map<std::string,std::string>&Config(void){return mConfig;}

	static void initConfig();
	static void initApplication(void);

	static std::string FindHomePath();

	static void LoadParameters(void);

	static int GetARGC(void){return _argc;}
	static char** GetARGV(void){return _argv;}

	const char* GetHomePath()const;

	static Application_App* _pcSingleton;

	Document_App* newDocument(const char* Name = 0l,const char* UserName = 0l);

	void closeAllDocuments(void);

	static std::string ws2s(const std::wstring& ws);
	static std::wstring s2ws(const std::string& s);

	ParameterManager &                                GetSystemParameter(void) ;
	/// returns the user parameter
	ParameterManager &                                GetUserParameter(void) ;


	std::map<std::string, std::string> getImportFilters(const char* Type) const;
	/// Return a list of all import filters.
	std::map<std::string, std::string> getImportFilters(void) const;


	std::map<std::string, std::string> getExportFilters(const char* Type) const;

	std::map<std::string, std::string> getExportFilters(void) const;

	std::vector<Document_App*> getDocuments() const;
	Document_App* getDocument(const char *Name) const;
	/// gets the (internal) name of the document
	const char * getDocumentName(const Document_App* ) const;

	Document_App* getActiveDocument();

	Base::Reference<ParameterGrp>                     GetParameterGroupByPath(const char* sName);

	 std::map<std::string,ParameterManager *> mpcPramManager;

private:

	static std::map<std::string,std::string> mConfig;
	std::map<std::string,std::string> _mConfig;

	std::map<std::string,Document_App*>DocMap;

	Document_App* _pActiveDoc;

	static int _argc;
	static char ** _argv;
	static ParameterManager *_pcSysParamMngr;
	static ParameterManager *_pcUserParamMngr;

	static Base::ConsoleObserverStd  *_pConsoleObserverStd;
	static Base::ConsoleObserverFile *_pConsoleObserverFile;


};

inline Application_App& GetApplication(void)
{
	return *Application_App::_pcSingleton;
}
#endif